package com.xymtop.sqlcater.core.sql.sqlparser.tosql.entity.sql;

import lombok.Data;

import java.util.List;

@Data
//解析的主节点
public class Element {
    //节点名称
    private String name;

    //节点解析前的内容
    private BaseNode content;

    //节点的解析后的SQL
    private String sql;

    //节点切割后的内容数组
    private List<SqlNode> sqlNodes;

    //节点是否已经解析完毕
    private Boolean isParse = false;



    //获取自己的SQL
    public String getBuildSql(){
        String sqlTemp = "";
        if(content.getValue().split(" ").length<2){
            sqlTemp = content.getValue();
        }else {
            for(SqlNode sqlNode :sqlNodes){
                if(sqlNode.getIsParse()){
                    sqlTemp = sqlTemp + " "+sqlNode.getSql();
                }
            }
        }
        this.sql = sqlTemp;
        return sql;
    }
}
